package com.wei.duowan.bbs.ui.activity;

import android.support.annotation.Nullable;
import android.support.design.widget.TabLayout;
import android.support.v4.app.Fragment;
import android.support.v4.app.FragmentManager;
import android.support.v4.app.FragmentStatePagerAdapter;
import android.support.v4.view.ViewPager;

import com.wei.duowan.bbs.R;
import com.wei.duowan.bbs.presenter.BasePresenter;
import com.wei.duowan.bbs.ui.fragment.ForumsIndexFragment;

import butterknife.Bind;

/**
 * 作者：赵若位
 * 时间：2019/8/2 16:28
 * 联系方式：1070138445
 * 功能：论坛列表
 */
public class FormumsActivity extends BaseActivity
{

    @Bind(R.id.viewPager)
    ViewPager mViewPager;
    @Bind(R.id.tabLayout)
    TabLayout mTabLayout;

    private String[] mTitle =
            {
                    "最新",
                    "置顶",
                    "精华",
                    "爆料",
                    "分享",
                    "攻略",
                    "新闻",
                    "活动",
                    "副本",
                    "杂谈",
                    "吐槽"
            };



    @Override
    protected BasePresenter createPresenter()
    {
        return null;
    }

    @Override
    protected int getLayoutID()
    {
        return R.layout.activity_forums;
    }

    @Override
    protected void initView()
    {
        setTitle("地下城与勇士");
        setFinish();
        ViewPagerAdapter adapter = new ViewPagerAdapter(getSupportFragmentManager());
        mViewPager.setAdapter(adapter);
        mTabLayout.setupWithViewPager(mViewPager);
    }


    private class ViewPagerAdapter extends FragmentStatePagerAdapter
    {
        public ViewPagerAdapter(FragmentManager fm)
        {
            super(fm);
        }

        @Override
        public Fragment getItem(int i)
        {
            return ForumsIndexFragment.getFragment(mTitle[i]);
        }

        @Override
        public int getCount()
        {
            return mTitle.length;
        }

        @Nullable
        @Override
        public CharSequence getPageTitle(int position)
        {
            return mTitle[position];
        }
    }

}
